﻿using System;
using ParboiledSharp.parboiled.dataobjects;
using ParboiledSharp.parboiled.rules;
using System.Diagnostics;

namespace ParboiledSharp
{
    class Program
    {
        static void Main()
        {
            TestRule test = new TestRule();
            Context context = new Context();
            context.SetStream("(2+2)*2");
            Rule rule = test.Expression();
            bool result = rule.Execute(context);

            object f = (System.Action<ValueStack>)PrintStack;
            object o = f;

            if (o is System.Action<ValueStack>)
            {
                ((System.Action<ValueStack>)o).Invoke(context.GetStack());
            }

            Console.ReadKey();
        }

        private static void showDebugInfo()
        {
            StackFrame stackFrame = new StackFrame(1, true);

            string method = stackFrame.GetMethod().ToString();
            Console.Out.WriteLine(method);

        }


        private static void PrintStack(ValueStack stack)
        {
            while (stack.Count() > 0)
            {
                object value = stack.Pop();
                Console.Out.WriteLine(value);
            }
        }

    }
}
